package com.dj.shop.controller;
import com.alibaba.fastjson.JSON;
import com.dj.shop.model.GoodsClass;
import com.dj.shop.poi.impl.FileInterfaceImpl;
import com.dj.shop.service.GoodClassService;
import com.dj.shop.util.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Set;

@Controller
@RequestMapping("/web/order/v1")
public class GoodClassController extends BaseController {


    private final Logger logger = LoggerFactory.getLogger(ManuController.class);


    @Autowired
    private  static GoodClassService goodClassService;


    @RequestMapping("/upload")
    //MultipartFile file, HttpServletResponse response
    public void upload() throws IOException {
        //注意头部内容必须和对象成员名字一致
        //返回所有excel对象的set集合
        //对象中不要出现非基本类型成员（String 除外）
        // String[] header={"name","phone","type","dept","number","idcard","birthDay","nickName","student"};
        String[] header = {"className","classDesc","classType","parentClassId"};
        Set<GoodsClass> rowCell= FileUtil.transFile(null,new FileInterfaceImpl(),header,GoodsClass.class);
        System.out.println( JSON.toJSON(rowCell));
        goodClassService.insert(rowCell);
    }




}
